﻿// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

pragma Singleton
import QtQuick

/*类比C/C++中的.h文件。
*/
Item {
    /*
    #define KCODE_K2_K3					(6)							//K2,K3同时按下。
    #define KCODE_K3_K4					(0xC)						//K3,K4同时按下。
    #define KEY_K1_ESC					(1)
    #define KEY_K2_OPT					(2)
    #define KEY_K3_MODE					(3)							//同级菜单向下切换。
    #define KEY_K4_ENTER				(4)
    #define KEY_K1_ESC_L				(KEY_K1_ESC | 0x80)			//长按
    #define KEY_K2_OPT_L				(KEY_K2_OPT | 0x80)			//长按
    #define KEY_K3_MODE_L				(KEY_K3_MODE | 0x80)		//长按
    #define KEY_K4_ENTER_L				(KEY_K4_ENTER | 0x80)		//长按
    */
    readonly property int key_esc: 1
    readonly property int key_opt: 2
    readonly property int key_mode: 4
    readonly property int key_enter: 8
    readonly property int key_esc_l:            (0x80+1)
    readonly property int key_opt_l:            (128+2)
    readonly property int key_mode_l:           (128+4)
    readonly property int key_enter_l:          (128+8)
    readonly property int key_k2_k3:            (6)
    readonly property int key_k3_k4:            (0x0C)      //可以写为HEX格式吗？
    readonly property int key_opt_mode:         (6)
    readonly property int key_mode_enter:       (0x0C)
    readonly property int vkey_rst:             (0xF0+ 0)   //虚拟按键，以0xF0为基准。


    /*通过BLE访问的虚拟地址[0,65535]
    操作寄存器（非参数寄存器）的虚拟寄存器在[0,100)。
    para_self结构体下参数对应的虚拟寄存器在[100,200)。
    para_xxx 结构体下参数对应的虚拟寄存器在[200,300)。
    如上定义，
    */
    readonly property int addr_cal_0:                       2
    readonly property int addr_cal_1:                       4
    readonly property int addr_cal_2:                       6
    readonly property int addr_cal_3:                       8
    readonly property int addr_cal_4:                       10

    readonly property int addr_laji_curve:                  50

    /*更多地址
    */
    readonly property int addr_com_plc_addr:                100
    readonly property int addr_com_plc_baud_idx:            102
    readonly property int addr_com_plc_mode_idx:            104
    readonly property int addr_com_plc_format_idx:          106
    readonly property int addr_com_interval_idx:            108
    readonly property int addr_com_protocol_idx:            110     //已作废。因为它和addr_com_plc_mode_idx是一个。

    //垃圾车
    readonly property int addr_laji_gap_min_idx:            130
    readonly property int addr_laji_gap_max_idx:            131
    readonly property int addr_laji_wt_hold_tmo_idx:        132
    readonly property int addr_lajitong_sample_cnt_idx:     137     //插入
    readonly property int addr_laji_gps_gap:                133
    readonly property int addr_laji_zzone_val:              134
    readonly property int addr_laji_zzone_tmo:              135
    readonly property int addr_laji_dtu_ip_port:            136     //需要特殊处理
    readonly property int addr_lajitong_dtu_mode:           138     //操，之前插入过137，这里用138吧。




    readonly property int addr_zero_auto_sw_idx:            200
    readonly property int addr_range_zero_trace_idx:        202
    readonly property int addr_range_stab_idx:              204
    readonly property int addr_range_zero:                  206
    readonly property int addr_filter_dig_idx:              208
    readonly property int addr_filter_stab_idx:             210
    readonly property int addr_sps_idx:                     212
    readonly property int addr_in1_define_idx:				213
    readonly property int addr_out1_define_idx:             214
    readonly property int addr_out2_define_idx:             215

    readonly property int addr_cal_pt_idx:                  220
    readonly property int addr_cal_fd_idx:                  221
    readonly property int addr_cal_cp:                      222
    readonly property int addr_cal_pwd:                     223


    readonly property int addr_rf_ch:                       250

    readonly property int addr_ver:                         251     //版本信息


    property int wHeight
    property int wWidth

    // Colors
    readonly property color backgroundColor: "#2d3037"
    readonly property color buttonColor: "#202227"
    readonly property color buttonPressedColor: "#6ccaf2"
    readonly property color disabledButtonColor: "#555555"
    readonly property color viewColor: "#202227"
    readonly property color delegate1Color: Qt.darker(viewColor, 1.2)
    readonly property color delegate2Color: Qt.lighter(viewColor, 1.2)
    readonly property color textColor: "#ffffff"
    readonly property color textDarkColor: "#232323"
    readonly property color disabledTextColor: "#777777"
    readonly property color sliderColor: "#6ccaf2"
    readonly property color errorColor: "#ba3f62"
    readonly property color infoColor: "#3fba62"

    // Font sizes
    property real microFontSize: hugeFontSize * 0.2
    property real tinyFontSize: hugeFontSize * 0.4
    property real smallTinyFontSize: hugeFontSize * 0.5
    property real smallFontSize: hugeFontSize * 0.6
    property real mediumFontSize: hugeFontSize * 0.7
    property real bigFontSize: hugeFontSize * 0.8
    property real largeFontSize: hugeFontSize * 0.9
    property real hugeFontSize: (wWidth + wHeight) * 0.03
    property real giganticFontSize: (wWidth + wHeight) * 0.04

    // Some other values
    property real fieldHeight: wHeight * 0.08
    property real fieldMargin: fieldHeight * 0.5
    property real buttonHeight: wHeight * 0.08              //QQ wHeight为定义，是0吗？
    property real buttonRadius: buttonHeight * 0.1

    // Some help functions  //为什么总叫helper?
    function widthForHeight(h, ss)
    {
        return h/ss.height * ss.width;  //C QQ 为什么ss有属性height？
    }

    function heightForWidth(w, ss)
    {
        return w/ss.width * ss.height;
    }

}
